
angular.module('mamApp').controller('modifyPasswordController', ['$scope', 'AuthManager', '$state','ImsAlert','ImsErr', function ($scope, AuthManager, $state,ImsAlert,ImsErr) {
    var mailCheck=$state.params.mailCheck;
    $scope.user={};
    $scope.disabled=false;

        $scope.confirm = function () {
            $scope.disabled=true;
            if($scope.user.newpwd!=$scope.user.oldpwd){
                AuthManager.resetPassword({newpwd:$scope.user.newpwd,oldpwd:$scope.user.oldpwd}).then(function (result) {
                    $scope.disabled=false;
                    if(result.data.c=="s"){
                        ImsAlert.open({message:"密码修改成功"}).then(function (a) {
                            $state.go("main.home")
                        })
                    }else {
                        ImsErr.open({message:result.data.i}).then(function (a) {
                        })
                    }
                })
            }else{
                $scope.disabled=false;
                ImsErr.open({message:"新密码和旧密码不能相同"}).then(function (a) {
                })
        }
    }


}])


